package xby.study.annotations.util;

import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class B {
    @GetMapping("/bbb")
    public void f() {
    }


    public static void main(String[] args) {

        try {
            Method m = B.class.getMethod("f", null);

            Annotation an = m.getAnnotation(GetMapping.class);



            System.out.println(an);
            System.out.println("-----------------------------------");

            RequestMapping a2 = AnnotationUtils.getAnnotation(an, RequestMapping.class);
            System.out.println(a2 );

            System.out.println("-----------------------------------");

            RequestMapping a3 = AnnotatedElementUtils.getMergedAnnotation(m, RequestMapping.class);
            System.out.println(a3 );




        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

    }
}
